package com.efun.center.controller;

import com.efun.center.entity.EmailServer;
import com.efun.center.entity.Page;
import com.efun.center.entity.ResultBean;
import com.efun.center.entity.search.EmailServerSearch;
import com.efun.center.http.service.DistributeService;
import com.efun.center.service.EmailServerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/emailServer")
@RestController
public class EmailServerController extends BaseController {

    @Autowired
    private EmailServerService emailServerService;

    @Autowired
    private DistributeService distributeService;

    @RequestMapping("/query")
    public ResultBean<Page<EmailServer>> queryServers(EmailServerSearch search){
        return returnSuccess(emailServerService.query(search));
    }

    @RequestMapping(value = "/delete")
    public String delete(String ids) {
        return distributeService.deleteEmailServer(ids);
    }

    @RequestMapping(value = "/save")
    public String save(EmailServer emailServer) {
        if (emailServer.getId() != null && emailServer.getId() > 0) {
            return distributeService.updateEmailServer(emailServer);
        } else {
            return distributeService.saveEmailServer(emailServer);
        }
    }

}
